package com.boang.atomic;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/*
    @author:sa
    @date:2024/11/27 15:31
*/
public class AtomiclntegerDemo {
    public static void main(String[] args) {
        AtomicInteger integer = new AtomicInteger();
        int i=integer.getAndAdd(1);
        System.out.println(i);
        ThreadPoolExecutor executor = new ThreadPoolExecutor(100, 155,
                30, TimeUnit.MINUTES, new ArrayBlockingQueue<>(5));
        for (int j = 0; j < 100; j++) {
            executor.submit(new Runnable() {
                @Override
                public void run() {
                    int i=integer.getAndAdd(1);
                    System.out.println(i);
                }
            });
        }
    }
}